package com.shanghaionstar.navi.base;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;

public abstract class BaseViewHolder extends RecyclerView.ViewHolder {

    public BaseViewHolder(View itemView) {
        super(itemView);
    }

    @SuppressWarnings("unchecked")
    protected <T extends View> T findViewById(int id) {
        View targetView = itemView.findViewById(id);
        return (targetView != null) ? (T) targetView : null;
    }

    public void setOnClickListener(View.OnClickListener listener) {
        itemView.setOnClickListener(listener);
    }

    public Context getContext() {
        return itemView.getContext();
    }
}
